using System.Data.Entity;
using System.Transactions;
using ElectronicGovernment.Infrastucture.EF;
using ElectronicGovernment.Infrastucture.Repositories;
using NUnit.Framework;

namespace ElectronicGovernment.Tests.Infrastructure.Repositories
{
    internal class RepositoryTestBase
    {
        private TransactionScope scope;

        [SetUp]
        public void BeginTransaction()
        {
            scope = new TransactionScope();
        }

        [TearDown]
        public void RollbackTransaction()
        {
            scope.Dispose();
        }

        [TestFixtureSetUp]
        public void SetupDatebase()
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges<DatabaseContext>());
            new GovernmentRepository().CountGovernments();
        }
    }
}